<template>
  <div class="app-container">
    <!-- <el-form
      ref="listFilterRef"
      :model="list.filter"
      inline
      class="list-filter"
    >
      <el-form-item prop="name">
        <el-input
          v-model="list.filter.name"
          placeholder="应用名称"
          maxlength="7"
          clearable
        />
      </el-form-item>
      <el-form-item>
        <el-button @click="reset">
          重置
        </el-button>
      </el-form-item>
    </el-form> -->

    <!-- <div class="table-operation">
      <AuthButton @click="c" name="新增" />
      <el-pagination
        v-bind="elPaginationProps"
        :total="list.total"
        :currentPage.sync="list.filter.pageNo"
        :pageSize.sync="list.filter.pageSize"
      />
    </div> -->
    <el-table v-loading="list.loading" :data="list.data" v-bind="tableProp">
      <el-table-column label="应用名称" prop="applicationName" />
      <el-table-column label="应用图标" prop="icon">
        <template slot-scope="scope">
          <PicViewer :value="scope.row.icon" tableCell />
        </template>
      </el-table-column>
      <el-table-column label="跳转资源名称" prop="sourceName" />
      <el-table-column label="修改时间" prop="updateTime" />
      <el-table-column label="启用状态" width="80" align="center">
        <template slot-scope="{ row: { id, status } }">
          <KiPopSwitch
            v-bind="popSwitchProps(status)"
            @change="updateStatus({ id, status: status ^ 1 })"
          />
        </template>
      </el-table-column>
      <el-table-column label="操作" class-name="small-padding">
        <template slot-scope="{ row }">
          <auth-button @click="u({ id: row.id })" name="编辑" />
          <!-- <auth-button @click="d({ id: row.id })" name="删除" /> -->
        </template>
      </el-table-column>
    </el-table>
    <KiFormDialog
      :show.sync="form.show"
      :title="formTitle"
      v-model="form.data"
      :submit="submitForm"
      :readonly="form.status === 'r'"
      ref="formRef"
      :loading="form.loading"
    >
      <template #el-form>
        <el-form-item label="应用名称" prop="applicationName" verify>
          <el-input
            v-model="form.data.applicationName"
            maxlength="7"
            show-word-limit
            placeholder="请输入应用名称"
          />
        </el-form-item>
        <el-form-item label="跳转页面" prop="sourceId" verify>
          <GlobalSearch
            v-if="form.show"
            v-model="form.data.sourceId"
            :type.sync="form.data.type"
            :sourceId.sync="form.data.sourceId"
            :sourceName.sync="form.data.sourceName"
          />
        </el-form-item>
        <el-form-item label="应用图标" prop="icon" verify>
          <Imgpond
            v-model="form.data.icon"
            :count="1"
            :editable="false"
            aspectRatio="1/1"
            :size="0.04"
          />
        </el-form-item>
      </template>
    </KiFormDialog>
  </div>
</template>

<script>
import pageMixin from '@/utils/pageMixin'
import useAdmateAdapter from '@/utils/useAdmateAdapter'

export default {
  mixins: [pageMixin],
  setup: () =>
    useAdmateAdapter({
      urlPrefix: 'one-travel-api/float-icon'
    })
}
</script>

<style lang="scss" scoped></style>
